//
//  OpenBlankViewController.m
//  WKWebViewDemo
//
//  Created by migu-hfy on 16/3/29.
//  Copyright © 2016年 migu-hfy. All rights reserved.
//

#import "OpenBlankViewController.h"
#import <WebKit/WebKit.h>

@interface OpenBlankViewController () <WKUIDelegate>

@property (nonatomic, strong) WKWebView *webView;

@end

@implementation OpenBlankViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    _webView = [[WKWebView alloc] initWithFrame:self.view.bounds];
    _webView.UIDelegate = self;
    [self.view addSubview:_webView];
    
    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"OpenBlank" ofType:@"html"];
    NSString *htmlString = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:NULL];
    
    [_webView loadHTMLString:htmlString baseURL:[NSBundle mainBundle].bundleURL];
}

- (WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures
{
    if (!navigationAction.targetFrame.isMainFrame) {
        
        [webView loadRequest:navigationAction.request];
    }
    
    return nil;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
